import { createApp } from 'vue'
import App from './App.vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import { createStore } from "vuex";
import {createRouter, createWebHashHistory} from "vue-router"
//引入路由组件
import VueMain from './components/VueMain.vue'
import VueContainer from './components/vuecontainer.vue'
//设置vuex4
const store =createStore({
    state(){
        return{
            zhuangtai:{
                isLoad:true,
                ismyinfo:false,
                ismmone:false,
                ismmtwo:false,
                iszhuce:false,
            }

        }
    },
    mutations:{
        // 改变state里的状态
        changemm(state){
            state.zhuangtai.ismmone=true
            state.zhuangtai.ismmtwo=false
            state.zhuangtai.ismyinfo=false
            state.zhuangtai.isLoad=false
            state.zhuangtai.iszhuce=false
        },
        denglu(state){
            state.zhuangtai.ismmone=false
            state.zhuangtai.ismmtwo=false
            state.zhuangtai.ismyinfo=false
            state.zhuangtai.isLoad=true
            state.zhuangtai.iszhuce=false
        },
        zhuce(state){
            state.zhuangtai.ismmone=false
            state.zhuangtai.ismmtwo=false
            state.zhuangtai.ismyinfo=false
            state.zhuangtai.isLoad=true
            state.zhuangtai.iszhuce=true
        },
        mmtwo(state){
            state.zhuangtai.ismmone=false
            state.zhuangtai.ismmtwo=true
            state.zhuangtai.ismyinfo=false
            state.zhuangtai.isLoad=false
            state.zhuangtai.iszhuce=false 
        },
        info(state){
            state.zhuangtai.ismmone=false 
            state.zhuangtai.ismmtwo=false 
            state.zhuangtai.ismyinfo=true
            state.zhuangtai.isLoad=false
            state.zhuangtai.iszhuce=false 
        }
    }
})
//设置路由组件
const router=createRouter({
    history:createWebHashHistory(),
    routes:[
        {
            path:'/',component:VueMain
        },
        {
            path:'/index',component:VueContainer
        },
    ]
})
//element plus 图标注册
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    createApp(App).component(key, component)
}
require('./mock/index.js')

const app=createApp(App)
app.use(ElementPlus)
app.use(store)
app.use(router)
app.mount('#app')